<template>
  <div class="search">
    <div class="search-box-wrapper">
      <search-box ref='searchBox' @query='onQueryChange'></search-box>
    </div>
    <div class="shortcut-wrapper" v-show='!query'>
      <div class="shortcut">
        <div class="hot-key">
          <h1 class="title">热门搜索</h1>
          <ul>
            <li class="item" v-for='(item, index) in hotKey' :key='index' @click='addQuery(item.k)'>
              <span>{{item.k}}</span>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="search-result" v-show='query'>
      <suggest :query='query'></suggest>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import SearchBox from 'base/search-box/search-box'
import Suggest from 'components/suggest/suggest'
export default {
  data() {
    return {
      hotKey: [
        {
          k: '天气之子',
          n: 11111
        },
        {
          k: '三藏',
          n: 33333
        },
        {
          k: '李宗盛',
          n: 55555
        },
        {
          k: '薛之谦',
          n: 44444
        },
        {
          k: '王力宏',
          n: 22222
        }
      ],
      query: ''
    }
  },
  computed: {
  },
  created() {
  },
  methods: {
    onQueryChange (query) {
      this.query = query
    },
    addQuery (query) {
      this.$refs.searchBox.setQuery(query)
    }
  },
  watch: {
  },
  components: {
    SearchBox,
    Suggest
  }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import "~common/stylus/variable"
  @import "~common/stylus/mixin"

  .search
    .search-box-wrapper
      padding: 10px 5px 10px 5px
      background: #eee
    .shortcut-wrapper
      position: fixed
      top: 160px
      bottom: 0
      width: 100%
      .shortcut
        height: 100%
        overflow: hidden
        .hot-key
          margin: 0 20px 20px 20px
          .title
            margin-bottom: 20px
            font-size: $font-size-medium
            color: #000
          .item
            display: inline-block
            padding: 5px 10px
            margin: 0 20px 10px 0
            border-radius: 6px
            background: #eee
            font-size: $font-size-medium
            color: #333
        .search-history
          position: relative
          margin: 0 20px
          .title
            display: flex
            align-items: center
            height: 40px
            font-size: $font-size-medium
            color: $color-text-l
            .text
              flex: 1
            .clear
              extend-click()
              .icon-clear
                font-size: $font-size-medium
                color: $color-text-d
    .search-result
      position: fixed
      width: 100%
      top: 148px
      bottom: 0
</style>